package ca.concordia.soen6461.wichf.controller;

import java.util.LinkedList;

public class ViewStack {
	
	private LinkedList<View<?>> stack = new LinkedList<View<?>>();
	
	public boolean isEmpty() {
		return stack.isEmpty();
	}
	
	public View<?> currentView() {
		return !isEmpty() ? stack.getLast() : null;
	}
	
	public void goTo(View<?> view) {
		if (view != currentView()) {
			stack.addLast(view);
		}
	}
	
	public void goBack() {
		if (!isEmpty()) {
			stack.removeLast();
		}
	}

	public void goHome() {
		if (!isEmpty()) {
			View<?> homeView = stack.getFirst();
			stack.clear();
			stack.addLast(homeView);
		}
	}

}
